import { request, formRequest } from '../utils/request';

export async function fetchCategoryList(params) {
  return request('prodapi/goods/getCatsList', {
    method: 'POST',
    body: params,
  });
}

export async function addCategory(params) {
  return request('prodapi/goods/addCats', {
    method: 'POST',
    body: params,
  });
}

export async function editCategory(params) {
  return request('prodapi/goods/updateCats', {
    method: 'POST',
    body: params,
  });
}

export async function deleteCategory(params) {
  return request('prodapi/goods/delCatsList', {
    method: 'POST',
    body: params,
  });
}


export async function fetchGoodsList(params) {
  return request('prodapi/goods/getGoodsCatsList', {
    method: 'POST',
    body: params,
  });
}

export async function fetchGoodsDetail(params) {
  return request('prodapi/goods/getGoodsCatsDetail', {
    method: 'POST',
    body: params,
  });
}


export async function addGoods(params) {
  let file = params.name;
  delete params.name;
  delete params.amount;
  delete params.authorName;

  return formRequest('prodapi/goods/upload/addCatsGoods', {
    method: 'POST',
    body: params,
  },
    file
  );
}

export async function editGoods(params) {
  let file = params.name;
  delete params.name;
  delete params.amount;
  delete params.authorName;

  return formRequest('prodapi/goods/upload/updateCatsGoods', {
    method: 'POST',
    body: params,
  },
    file
  );
}

export async function upGoodsList(params) {
  return request('prodapi/goods/upGoodsScoreList', {
    method: 'POST',
    body: params,
  });
}

export async function downGoodsList(params) {
  return request('prodapi/goods/downGoodsScoreList', {
    method: 'POST',
    body: params,
  });
}

export async function delGoodsList(params) {
  return request('prodapi/goods/delGoodsScoreList', {
    method: 'POST',
    body: params,
  });
}

export async function addImage(params) {
  let file = params;
  console.log('上传的图片-----' + file)
  return formRequest('prodapi/goods/upload/addGoodsShowImg', {
    method: 'POST',
    body: {},
  },
    file
  );
}



export async function fetchPositionList(params) {
  return request('prodapi/goods/getOperationPositionList', {
    method: 'POST',
    body: params,
  });
}

export async function fetchScoreGoodsList(params) {
  return request('prodapi/goods/getScoreGoodsList', {
    method: 'POST',
    body: params,
  });
}

export async function addPosition(params) {
  console.log('service----------------------', params)
  let file = params.name;
  delete params.name;

  return formRequest('prodapi/goods/upload/addOperationPosition', {
    method: 'POST',
    body: params,
  },
    file
  );
}

export async function editPosition(params) {
  let file = params.name;
  delete params.name;

  return formRequest('prodapi/goods/upload/updateOperationPosition', {
    method: 'POST',
    body: params,
  },
    file
  );
}

